<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ca="http://java.sun.com/jsf/composite/cashSummery"
                xmlns:pe="http://primefaces.org/ui/extensions">

    <ui:define name="content">
        <h:outputStylesheet library="css" name="printing.css"></h:outputStylesheet>
        <h:form >



            <p:panel>
                <f:facet name="header" >                
                    <h:outputLabel value="Inward Lab Summary by Added Date"/>
                </f:facet>


                <h:panelGrid columns="2">
                    <h:outputLabel value="From Date"/>
                    <p:calendar id="frmDate" value="#{serviceSummery.fromDate}" navigator="true"  pattern="dd MMMM yyyy  HH:mm:ss" >
                    </p:calendar>

                    <h:outputLabel value="To Date"/>
                    <p:calendar id="toDate" value="#{serviceSummery.toDate}" navigator="true" pattern="dd MMMM yyyy  HH:mm:ss" >
                    </p:calendar>

                    <h:outputLabel value="Department" ></h:outputLabel>
                    <p:autoComplete completeMethod="#{departmentController.completeDept}" var="dept" itemLabel="#{dept.name}" itemValue="#{dept}" forceSelection="true" value="#{serviceSummery.department}" converter="departmentConverter" >
                    </p:autoComplete>

                    <h:outputLabel value="Instituion"/>
                    <p:autoComplete styleClass="noPrintButton"  value="#{serviceSummery.institution}"  
                                    completeMethod="#{institutionController.completeCompany}" var="dept" itemValue="#{dept}" itemLabel="#{dept.name}" forceSelection="true" rendered="true" requiredMessage="You must select a department" >
                    </p:autoComplete>

                    <h:outputLabel value="Service Name"/>
                    <p:autoComplete value="#{serviceSummery.service}" completeMethod="#{itemController.completeItem}" var="ix" 
                                    itemLabel="#{ix.name}" itemValue="#{ix}" size="30"  style="width: 400px;" forceSelection="true" >
                        <p:column>
                            #{ix.name}
                        </p:column>
                        <p:column>
                            #{ix.department.name}
                        </p:column>  
                        <p:column>
                            #{ix.category.name}
                        </p:column> 
                    </p:autoComplete>

                </h:panelGrid>
                <h:panelGrid columns="5">
                    <p:spacer height="1" width="110"/>
                    <p:commandButton id="btnRefresh" value="Process" ajax="false" 
                                     styleClass="noPrintButton" style="float: right;" 
                                     action="#{serviceSummery.createServiceSummeryInwardAddedDate()}"/>
                    <p:defaultCommand target="btnRefresh"/>

                    <p:commandButton ajax="false" value="Print"  
                                     styleClass="noPrintButton" style="float: right;" >
                        <p:printer target="panelPrint" />
                    </p:commandButton>

                    <p:commandButton value="Excel" ajax="false" style="float: right;">
                        <pe:exporter type="xlsx" target="opd" fileName="Service_Lab_Summery"  />
                    </p:commandButton>
                </h:panelGrid>

            </p:panel>

            <p:spacer height="30"/>
            <p:panel id="panelPrint" styleClass="noBorder summeryBorder">
                <p:dataTable id="opd" rowIndexVar="i" 
                             rowStyleClass="#{d.billItem.bill.cancelled or d.billItem.bill.billedBill ne null?'crossLine':''}"
                             value="#{serviceSummery.serviceSummery}" var="d"
                             rows="20"
                             paginator="true"
                             paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
                             rowsPerPageTemplate="20, 50, 100" 
                             >                   

                    <f:facet name="header">
                        <h:outputLabel value="#{serviceSummery.service.name}"/>
                        <h:outputLabel value=" : "/>
                        <h:outputLabel value="#{serviceSummery.fromDate}">
                            <f:convertDateTime pattern="dd MMMM yyyy"/>
                        </h:outputLabel>
                        <h:outputLabel value="--"/>
                        <h:outputLabel value="#{serviceSummery.toDate}">
                            <f:convertDateTime pattern="dd MMMM yyyy"/>
                        </h:outputLabel>
                    </f:facet>

                    <p:column headerText="No">
                        <f:facet name="header">
                            <p:outputLabel value="No"/>
                        </f:facet>
                        <h:outputLabel value="#{i+1}"/>
                    </p:column>

                    <p:column headerText="Bill No"
                              sortBy="#{d.billItem.bill.insId}" 
                              filterBy="#{d.billItem.bill.insId}"
                              filterMatchMode="contains">
                        <f:facet name="header">
                            <p:outputLabel value="Bill No"/>
                        </f:facet>
                        <p:outputLabel value="#{d.billItem.bill.insId}" />
                    </p:column>

                    <p:column headerText="Billed Bill No"
                              sortBy="#{d.billItem.bill.billedBill.insId}"
                              filterBy="#{d.billItem.bill.billedBill.insId}"
                              filterMatchMode="contains">
                        <f:facet name="header">
                            <p:outputLabel value="Billed Bill No"/>
                        </f:facet>
                        <p:outputLabel value="#{d.billItem.bill.billedBill.insId}" />
                    </p:column>

                    <p:column headerText="BHT No"
                              sortBy="#{d.billItem.bill.patientEncounter.bhtNo}" 
                              filterBy="#{d.billItem.bill.patientEncounter.bhtNo}"
                              filterMatchMode="contains">
                        <f:facet name="header">
                            <h:outputLabel value="BHT No" />
                        </f:facet>
                        <p:outputLabel value="#{d.billItem.bill.patientEncounter.bhtNo}" />
                        <f:facet name="footer">
                            <h:outputLabel value="COUNT  (#{serviceSummery.count})">                                   
                            </h:outputLabel>
                        </f:facet>
                    </p:column>

                    <p:column headerText="Date"
                              sortBy="#{d.billItem.createdAt}" 
                              filterBy="#{d.billItem.createdAt}"
                              filterMatchMode="contains">
                        <f:facet name="header">
                            <p:outputLabel value="Date"/>
                        </f:facet>
                        <h:outputLabel value="#{d.billItem.createdAt}">
                            <f:convertDateTime pattern="dd MMMM yyyy"/>
                        </h:outputLabel>
                    </p:column>

                    <p:column headerText="Actual Date"
                              sortBy="#{d.billItem.billTime}" 
                              filterBy="#{d.billItem.billTime}"
                              filterMatchMode="contains">
                        <f:facet name="header">
                            <p:outputLabel value="Actual Date"/>
                        </f:facet>
                        <h:outputLabel value="#{d.billItem.billTime}">
                            <f:convertDateTime pattern="dd MMMM yyyy"/>
                        </h:outputLabel>
                    </p:column>

                    <p:column headerText="Professional Fee" styleClass="averageNumericColumn">
                        <f:facet name="header">
                            <h:outputLabel value="Professional Fee" />
                        </f:facet>
                        <p:outputLabel value="#{d.proFee}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </p:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{serviceSummery.proFeeTotal}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>

                    <p:column headerText="Hospital Fee" styleClass="averageNumericColumn">
                        <f:facet name="header">
                            <p:outputLabel value="Hospital Fee"/>
                        </f:facet>
                        <p:outputLabel value="#{d.hospitalFee}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </p:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{serviceSummery.hosFeeTotal}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>     

                    <p:column headerText="Out Fee" styleClass="averageNumericColumn">
                        <f:facet name="header">
                            <p:outputLabel value="Out Fee"/>
                        </f:facet>
                        <p:outputLabel value="#{d.outSideFee}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </p:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{serviceSummery.outSideFeeTotoal}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>

                    <p:column headerText="Regent Fee" styleClass="averageNumericColumn">
                        <f:facet name="header">
                            <p:outputLabel value="Regent Fee"/>
                        </f:facet>
                        <p:outputLabel value="#{d.reagentFee}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </p:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{serviceSummery.reagentFeeTotal}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column> 

                    <p:column headerText="Total Fee" styleClass="averageNumericColumn">
                        <f:facet name="header">
                            <p:outputLabel value="Total Fee"/>
                        </f:facet>
                        <p:outputLabel value="#{d.proFee+d.hospitalFee+d.outSideFee+d.reagentFee}">
                            <f:convertNumber pattern="#,##0.00"/>
                        </p:outputLabel>
                        <f:facet name="footer">
                            <h:outputLabel value="#{serviceSummery.proFeeTotal+serviceSummery.hosFeeTotal+serviceSummery.outSideFeeTotoal+serviceSummery.reagentFeeTotal}">
                                <f:convertNumber pattern="#,##0.00"/>
                            </h:outputLabel>
                        </f:facet>
                    </p:column>              
                </p:dataTable> 
            </p:panel>
        </h:form>
    </ui:define>


</ui:composition>
